import { Message, MessageBox, Loading } from 'element-ui';
import _ from 'lodash';

let messageConfig={
     showClose: true
}
let success = (message = "操作成功", options) => {
    var options = _.assign({
        message: message,
        type: 'success'
    },messageConfig, options);
    return Message(options);
}

let info = (message, options) => {
    var options = _.assign({
        message: message,
    },messageConfig, options);
    return Message(options);
}

let warning = (message, options) => {
    var options = _.assign({
        message: message,
        type: 'warning'
    },messageConfig, options);
    return Message(options);
}

let error = (message = "操作失败", options) => {
    var options = _.assign({
        message: message,
        type: 'error'
    },messageConfig, options);
    return Message(options);
}

let loading = (message = "加载中", options) => {
    return Loading.service(options);
}

let confirm = (title = "询问", message = "询问", options) => {
    return MessageBox(_.assign({
        title:title,
        message:message,
        type: 'warning',
        showCancelButton:true,
        confirmButtonText: '确定',
        cancelButtonText: '取消'
    }, options));
}


export default{
    success,
    info,
    warning,
    error,
    loading,
    confirm
}